package com.cashoutgaming.client.modules.application;

import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl;
import com.sencha.gxt.widget.core.client.container.Viewport;

/**
 * The main desktop view
 * 
 * This has a viewport which is the highest level container
 */
public class ApplicationView extends ViewImpl implements ApplicationPresenter.MyView {

	Viewport mainContentPanel = new Viewport();

	@Inject
	public ApplicationView() {
		this.initWidget(mainContentPanel);
		mainContentPanel.addResizeHandler(new ResizeHandler() {

			@Override
			public void onResize(ResizeEvent event) {
				mainContentPanel.forceLayout();
			}
		});
	}

	@Override
	public void setInSlot(Object slot, IsWidget content) {
		if (slot == ApplicationPresenter.TYPE_SetMainContent) {
			mainContentPanel.setWidget(content);
		}
		else {
			super.setInSlot(slot, content);
		}
		mainContentPanel.forceLayout();
	}
}
